package cn.lingyangwl.agile.food.core.model.rqrs.cart;

import cn.lingyangwl.agile.food.model.rqrs.goods.GoodsResp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;

/**
 * 购物车
 *
 * @author shenguangyang
 */
@Getter
@Setter
@ApiModel(value = "购物车")
public class CartResp {
	@ApiModelProperty(value = "商品信息")
	private List<Goods> goodsList = Collections.emptyList();

	@ApiModelProperty(value = "购物车信息")
	private Info cartInfo;

	/**
	 * 购物车中的商品
	 */
	@Getter
	@Setter
	@Accessors(chain = true)
	public static class Goods extends GoodsResp {
		@ApiModelProperty(value = "购物车中该商品描述, 规格 + 属性")
		private String describe;

		@ApiModelProperty(value = "购物车id")
		private Long cartId;

		@ApiModelProperty(value = "属性附加价格")
		private BigDecimal attrAdditionalPrice = BigDecimal.ZERO;

		@ApiModelProperty(value = "总价格")
		private BigDecimal totalPrice;

		public BigDecimal getTotalPrice() {
			return this.getPrice().add(attrAdditionalPrice);
		}
	}


	@Data
	public static class Info {
		@ApiModelProperty(value = "购物车总数量")
		private Integer cartTotalNum = 0;

		@ApiModelProperty(value = "总商品金额")
		private BigDecimal totalGoodsPrice = BigDecimal.ZERO;

		@ApiModelProperty(value = "总划线价钱")
		private BigDecimal totalLinePrice = BigDecimal.ZERO;

		@ApiModelProperty(value = "总包装费")
		private BigDecimal totalBagPrice = BigDecimal.ZERO;

		@ApiModelProperty(value = "总价格")
		private BigDecimal totalPrice = BigDecimal.ZERO;

		public BigDecimal getTotalPrice() {
			return totalGoodsPrice.add(totalBagPrice);
		}
	}
}
